#include <QLibrary>
#include <QDebug>
#include "syncbase6rwtest.h"
#include "ui_syncbase6rwtest.h"

#define A2T QString::fromLocal8Bit()

SyncBase6RWTest::SyncBase6RWTest(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::SyncBase6RWTest)
{
    ui->setupUi(this);
    initModule();
}

SyncBase6RWTest::~SyncBase6RWTest()
{
    delete ui;
}

void SyncBase6RWTest::initModule()
{
    QString sPath = QCoreApplication::applicationDirPath();
    QString libraryPath;
#ifdef WIN32
    // 在Windows环境下加载 SyncBase6RW.dll
    libraryPath = sPath+"/SyncBase6RW.dll";  // 设置库文件路径
#elif defined(__linux__) || defined(__unix__)
    // 在Linux环境下加载 libSyncBase6RW.so
    libraryPath = sPath+"/libSyncBase6RW.so";  // 设置库文件路径
#else
    return;
#endif
    m_pLib = new QLibrary(libraryPath);
    if (m_pLib->load())
    {
        m_lpGetModelPtr = (GETMODULEPTREX)m_pLib->resolve("getModulePtrEx");
        if (m_lpGetModelPtr != nullptr)
        {
            m_pModule = m_lpGetModelPtr();
        }
        if (m_pModule != nullptr)
        {

        }
    }
    else
    {
        qDebug()<<QString::fromLocal8Bit("加载SyncBase失败,原因:%1").arg(m_pLib->errorString());
    }
}
